package com.qfmy.web.entity.login;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.groups.Default;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;

import java.time.LocalDateTime;

/**
 * @author: 廖志伟
 * @date: 2024-11-28
 * @Description: 登录用户实体类
 */
@SuppressWarnings("all")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LoginUser {
    //提供一个接口用来区分校验规则 -> 注册校验规则
    public interface Register extends Default {}
    //提供一个接口用来区分校验规则 -> 登录校验规则
    public interface Login extends Default {}

    @Id
    private Long id;

    @NotEmpty
    private String username;

    @NotEmpty
    private String password;

    //用户手机号
    @NotEmpty(groups = {Register.class})
    @Pattern(regexp = "^1[3-9]\\d{11}$", message = "手机号格式错误")
    private String phone;

    //用户头像
    private String userPic;

    /**
     * @return 创建时间
     */
    @JsonIgnore
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;

    /**
     * @return 修改时间
     */
    @JsonIgnore
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime updateTime;

}
